package uniriotec.dsw.tickets.modelo;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.ManyToOne;
import javax.persistence.Column;

import org.hibernate.validator.NotNull;



@Entity
public class Acao implements Serializable{

    /**
	 * 
	 */
	private static final long serialVersionUID = -4651332200708987232L;
	@Id
    @GeneratedValue
    private Integer id;
	
    @Temporal(TemporalType.DATE)
    @NotNull
    private Date dataHora;
    
    @ManyToOne
    @NotNull
    private Usuario usuario;
    
    @ManyToOne
    @NotNull
    private Ticket ticket;
    
    @ManyToOne
    @NotNull
    private Status status;
    
    @Column(length = 200)
    private String comentario;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataHora() {
        return dataHora;
    }

    public void setDataHora(Date dataHora) {
        this.dataHora = dataHora;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public Ticket getTicket() {
        return ticket;
    }

    public void setTicket(Ticket ticket) {
        this.ticket = ticket;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public String getComentario() {
        return comentario;
    }

    public void setComentario(String comentario) {
        this.comentario = comentario;
    }

    public boolean isNovo() {
        if (id == null) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        Acao other = (Acao) obj;
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Acao [id="
                + id
                + ", data e hora="
                + dataHora
                + ", usuario="
                + usuario.getNome()
                + ", ticket="
                + ticket.getDescricao()
                + ", status="
                + status.getDescricao()
                + "]";
    }
}
